<template>
	<view>
		<view style="padding: 30rpx; text-align: right;"> <uni-button size="mini"  type="primary" @click="addCategory()">新增分类</uni-button></view>
		<view class="">
			<uni-card v-for="(item, index) in dataList" :key="index" :title="item.cat_name" >
<!-- 				<text class="uni-body">产品：</text>
				<text class="uni-body">员工：</text>
				<text class="uni-body">库存：</text> -->
			</uni-card>
		</view>
		<uni-load-more iconType="auto" :status="status" />
		
	</view>
	

</template>



<script>

	import api from "@/utils/api.js";
	export default {
		data() {
			return {
				dataList: [],
				status: 'more',
				statusTypes: [{
					value: 'more',
					text: '加载更多',
					checked: true
				}, {
					value: 'loading',
					text: '加载中...',
					checked: false
				}, {
					value: 'noMore',
					text: '没有更多的数据啦。',
					checked: false
				}],
			}
		},
		onShow() {
			this.fetchData();
		},
		methods: {
			addCategory(){
				uni.navigateTo({
					url: "/pages/kucun/category/add"
				})
			},
			async fetchData(){
				this.status = "loading";
				let { result } = await api.categoryList();
				console.log(result)
				
					
				if(result['data']['list'].length == 0) {
					this.status = "noMore"
				}else{
					this.status = "more"
				}
				this.dataList = result['data']['list']
			}
		}
	}
</script>

<style>

</style>
